package listeners

import (
	"fmt"
	"gin_study/app/event_manager"
	"gin_study/app/events"
)

type PrintMyNameAfterFetchUserListener struct {
	events []interface{}
}

func (p *PrintMyNameAfterFetchUserListener) Handler(e interface{}) {
	if va, ok := e.(events.FetchUserEvent); ok {
		fmt.Println(va.Name, "PrintMyNameAfterFetchUserListener")
	}
}

func (p *PrintMyNameAfterFetchUserListener) SetEvents() {
	p.events = append(p.events, events.FetchUserEvent{})
}

func (p *PrintMyNameAfterFetchUserListener) GetListenerEvents() []interface{} {
	return p.events
}

func init() {
	p := new(PrintMyNameAfterFetchUserListener)
	event_manager.EM.Register(p)
}
